package com.example.flightsearch.data

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import kotlinx.coroutines.flow.Flow

@Dao
interface FavoriteDao {
    @Query("SELECT COUNT(*) FROM favorite WHERE departure_code = :departureCode AND destination_code = :destinationCode")
    fun countByDepartureCodeAndDestinationCode(departureCode: String, destinationCode: String): Flow<Int>

    @Delete(Favorite::class)
    suspend fun deleteByDepartureCodeAndDestinationCode(favorite: FavoriteDepartureCodeAndDestinationCode)

    @Insert
    suspend fun insert(favorite: Favorite)
}